package nc.ui.uif2.actions;

import java.awt.event.ActionEvent;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.UIState;
import nc.ui.uif2.model.AbstractAppModel;

public class AddAction extends NCAction
{
  private static final long serialVersionUID = 1L;
  protected AbstractAppModel model = null;

  public AddAction()
  {
    ActionInitializer.initializeAction(this, 1);
  }

  public void doAction(ActionEvent e) throws Exception
  {
    this.model.setUiState(UIState.ADD);
  }

  protected boolean isActionEnable()
  {
    return this.model.getUiState() == UIState.NOT_EDIT;
  }

  public AbstractAppModel getModel()
  {
    return this.model;
  }

  public void setModel(AbstractAppModel model) {
    this.model = model;
    model.addAppEventListener(this);
  }
}